﻿Public Class CrashTrend

    Private Sub rad单月_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rad单年.Click, rad收入.Click, rad支出.Click, rad单月.Click, rad统计日.Click, rad统计月.Click

        If Me.rad单月.Checked Then
            Me.gp月.Text = "月"
            Me.Label1.Text = "开始月"
            Me.Label3.Text = "结束月"
            Me.dt开始月.CustomFormat = "yyyy年MM月"
            Me.dt结束月.CustomFormat = "yyyy年MM月"

            rad统计日.Text = "日"
            rad统计月.Text = "月"
        End If

        If Me.rad单年.Checked Then
            Me.gp月.Text = "年"
            Me.Label1.Text = "开始年"
            Me.Label3.Text = "结束年"
            Me.dt开始月.CustomFormat = "yyyy年"
            Me.dt结束月.CustomFormat = "yyyy年"

            rad统计日.Text = "月"
            rad统计月.Text = "年"
        End If
    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click

        If rad收入.Checked Then
            ReportConst.TypeTrend1 = 0
        End If

        If rad支出.Checked Then
            ReportConst.TypeTrend1 = 1
        End If
        Dim cv As New CrystlViewer

        If rad单月.Checked Then
            ReportConst.TypeTrend = 0
        End If

        If rad单年.Checked Then
            ReportConst.TypeTrend = 1
        End If

        cv._ParamsValues.Add("开始时间", Me.dt开始月.Value)
        cv._ParamsValues.Add("结束时间", Me.dt结束月.Value)

        If rad统计日.Checked Then
            ReportConst.TypeTrend2 = 0
        Else
            ReportConst.TypeTrend2 = 1
        End If

        If Not Check() Then
            Return
        End If

        Me.Visible = False
        If rad收入.Checked Then
            cv._ParamsValues.Add("TITLE", "收入趋势表")
        Else
            cv._ParamsValues.Add("TITLE", "支出趋势表")
        End If

        cv._Rt = CrystlViewer.ReportType.Trend
        Using cv
            cv.ShowDialog()
        End Using

        Me.Close()
    End Sub

    Private Function Check() As Boolean
        'If rad单月.Checked Then
        '    If Me.dt结束月.Value < Me.dt开始月.Value Then
        '        dt开始月.Focus()
        '        ShowMessageBox("开始月不能大于结束月")
        '        Return False
        '    End If
        'End If

        'If rad单年.Checked Then
        '    If Me.dt结束月.Value < Me.dt开始月.Value Then
        '        dt开始月.Focus()
        '        ShowMessageBox("开始年不能大于结束年")
        '        Return False
        '    End If
        'End If
        Return True
    End Function
End Class
